package com.scalar.chiptrack.operations.process.cycleTime.actions;

import com.scalar.chiptrack.ChipTrackAction;
import com.scalar.chiptrack.operations.process.cycleTime.actioncommands.StageCycleTimeActionCommandFactory;
import com.scalar.chiptrack.actioncommands.ActionCommand;
import com.scalar.chiptrack.commons.SessionKeys;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForm;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;

/**
 * Created By Ganesh
 * Date  : Apr 3, 2006
 * Time  : 3:00:29 PM
 */
public class StageCycleTimeAction extends ChipTrackAction implements SessionKeys
{
    public ActionForward execute (ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception
    {

        HashMap errors = new HashMap();
        request.setAttribute( ERROR_MESSAGES, errors );

        ActionForward actionForward = mapping.findForward( "success" );
        String action 				= request.getParameter( "action" ) ;

        try
        {
            ActionCommand stageCycleTimeCommand  = null;
            stageCycleTimeCommand 	            = StageCycleTimeActionCommandFactory.getActionCommand( action );
            actionForward 			            = stageCycleTimeCommand.execute( mapping, form, request, response );

        }
        catch( Exception e )
        {
            errors.put( "Unable to load the Stage Cycle Time Screen" , null );
            actionForward = mapping.findForward( "search" );
        }
        return actionForward;
    }
}
